import { makeAutoObservable } from 'mobx';
import { inject, injectable } from 'inversify';
import { UserModel } from '../models/user.model.ts';
import { APIClient } from '@todo/core';

@injectable()
export class LogoutUseCase {
  constructor(
    @inject(UserModel)
    private userModel: UserModel,
    @inject(APIClient)
    private apiClient: APIClient,
  ) {
    makeAutoObservable(this);
  }

  execute(): void {
    this.userModel.dispose();
    this.userModel.authenticated = false;
    this.apiClient.removeCookies();
  }
}
